{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Think Bayes: Chapter 2\n",
    "\n",
    "This notebook presents example code and exercise solutions for Think Bayes.\n",
    "\n",
    "Copyright 2016 Allen B. Downey\n",
    "\n",
    "MIT License: https://opensource.org/licenses/MIT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function, division\n",
    "\n",
    "% matplotlib inline\n",
    "\n",
    "from thinkbayes2 import Hist, Pmf, Suite"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Pmf class\n",
    "\n",
    "I'll start by making a Pmf that represents the outcome of a six-sided die.  Initially there are 6 values with equal probability."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1\n",
      "2 1\n",
      "3 1\n",
      "4 1\n",
      "5 1\n",
      "6 1\n"
     ]
    }
   ],
   "source": [
    "pmf = Pmf()\n",
    "for x in [1,2,3,4,5,6]:\n",
    "    pmf[x] = 1\n",
    "    \n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To be true probabilities, they have to add up to 1.  So we can normalize the Pmf:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pmf.Normalize()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The return value from `Normalize` is the sum of the probabilities before normalizing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 0.166666666667\n",
      "2 0.166666666667\n",
      "3 0.166666666667\n",
      "4 0.166666666667\n",
      "5 0.166666666667\n",
      "6 0.166666666667\n"
     ]
    }
   ],
   "source": [
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A faster way to make a Pmf is to provide a sequence of values.  The constructor adds the values to the Pmf and then normalizes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 0.166666666667\n",
      "2 0.166666666667\n",
      "3 0.166666666667\n",
      "4 0.166666666667\n",
      "5 0.166666666667\n",
      "6 0.166666666667\n"
     ]
    }
   ],
   "source": [
    "pmf = Pmf([1,2,3,4,5,6])\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To extract a value from a Pmf, you can use `Prob`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.16666666666666666"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pmf.Prob(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or you can use the bracket operator.  Either way, if you ask for the probability of something that's not in the Pmf, the result is 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.16666666666666666"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pmf[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The cookie problem\n",
    "\n",
    "Here's a Pmf that represents the prior distribution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.5\n",
      "Bowl 2 0.5\n"
     ]
    }
   ],
   "source": [
    "pmf = Pmf()\n",
    "pmf['Bowl 1'] = 0.5\n",
    "pmf['Bowl 2'] = 0.5\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we can update it using `Mult`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.375\n",
      "Bowl 2 0.25\n"
     ]
    }
   ],
   "source": [
    "pmf.Mult('Bowl 1', 0.75)\n",
    "pmf.Mult('Bowl 2', 0.5)\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or here's the shorter way to construct the prior."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.5\n",
      "Bowl 2 0.5\n"
     ]
    }
   ],
   "source": [
    "pmf = Pmf(['Bowl 1', 'Bowl 2'])\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we can use `*=` for the update."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.375\n",
      "Bowl 2 0.25\n"
     ]
    }
   ],
   "source": [
    "pmf['Bowl 1'] *= 0.75\n",
    "pmf['Bowl 2'] *= 0.5\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Either way, we have to normalize the posterior distribution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.6\n",
      "Bowl 2 0.4\n"
     ]
    }
   ],
   "source": [
    "pmf.Normalize()\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Bayesian framework\n",
    "\n",
    "Here's the same computation encapsulated in a class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class Cookie(Pmf):\n",
    "    \"\"\"A map from string bowl ID to probablity.\"\"\"\n",
    "\n",
    "    def __init__(self, hypos):\n",
    "        \"\"\"Initialize self.\n",
    "\n",
    "        hypos: sequence of string bowl IDs\n",
    "        \"\"\"\n",
    "        Pmf.__init__(self)\n",
    "        for hypo in hypos:\n",
    "            self.Set(hypo, 1)\n",
    "        self.Normalize()\n",
    "\n",
    "    def Update(self, data):\n",
    "        \"\"\"Updates the PMF with new data.\n",
    "\n",
    "        data: string cookie type\n",
    "        \"\"\"\n",
    "        for hypo in self.Values():\n",
    "            like = self.Likelihood(data, hypo)\n",
    "            self.Mult(hypo, like)\n",
    "        self.Normalize()\n",
    "\n",
    "    mixes = {\n",
    "        'Bowl 1':dict(vanilla=0.75, chocolate=0.25),\n",
    "        'Bowl 2':dict(vanilla=0.5, chocolate=0.5),\n",
    "        }\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        \"\"\"The likelihood of the data under the hypothesis.\n",
    "\n",
    "        data: string cookie type\n",
    "        hypo: string bowl ID\n",
    "        \"\"\"\n",
    "        mix = self.mixes[hypo]\n",
    "        like = mix[data]\n",
    "        return like"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can confirm that we get the same result."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.6\n",
      "Bowl 2 0.4\n"
     ]
    }
   ],
   "source": [
    "pmf = Cookie(['Bowl 1', 'Bowl 2'])\n",
    "pmf.Update('vanilla')\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But this implementation is more general; it can handle any sequence of data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bowl 1 0.627906976744\n",
      "Bowl 2 0.372093023256\n"
     ]
    }
   ],
   "source": [
    "dataset = ['vanilla', 'chocolate', 'vanilla']\n",
    "for data in dataset:\n",
    "    pmf.Update(data)\n",
    "    \n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Monty Hall problem\n",
    "\n",
    "The Monty Hall problem might be the most contentious question in\n",
    "the history of probability.  The scenario is simple, but the correct\n",
    "answer is so counterintuitive that many people just can't accept\n",
    "it, and many smart people have embarrassed themselves not just by\n",
    "getting it wrong but by arguing the wrong side, aggressively,\n",
    "in public.\n",
    "\n",
    "Monty Hall was the original host of the game show *Let's Make a\n",
    "Deal*.  The Monty Hall problem is based on one of the regular\n",
    "games on the show.  If you are on the show, here's what happens:\n",
    "\n",
    "*  Monty shows you three closed doors and tells you that there is a\n",
    "   prize behind each door: one prize is a car, the other two are less\n",
    "   valuable prizes like peanut butter and fake finger nails.  The\n",
    "   prizes are arranged at random.\n",
    "\n",
    "*  The object of the game is to guess which door has the car.  If\n",
    "   you guess right, you get to keep the car.\n",
    "\n",
    "*  You pick a door, which we will call Door A.  We'll call the\n",
    "   other doors B and C.\n",
    "\n",
    "*  Before opening the door you chose, Monty increases the\n",
    "   suspense by opening either Door B or C, whichever does not\n",
    "   have the car.  (If the car is actually behind Door A, Monty can\n",
    "   safely open B or C, so he chooses one at random.)\n",
    "\n",
    "*  Then Monty offers you the option to stick with your original\n",
    "   choice or switch to the one remaining unopened door.\n",
    "\n",
    "The question is, should you \"stick\" or \"switch\" or does it\n",
    "make no difference?\n",
    "\n",
    "Most people have the strong intuition that it makes no difference.\n",
    "There are two doors left, they reason, so the chance that the car\n",
    "is behind Door A is 50%.\n",
    "\n",
    "But that is wrong.  In fact, the chance of winning if you stick\n",
    "with Door A is only 1/3; if you switch, your chances are 2/3.\n",
    "\n",
    "Here's a class that solves the Monty Hall problem."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class Monty(Pmf):\n",
    "    \"\"\"Map from string location of car to probability\"\"\"\n",
    "\n",
    "    def __init__(self, hypos):\n",
    "        \"\"\"Initialize the distribution.\n",
    "\n",
    "        hypos: sequence of hypotheses\n",
    "        \"\"\"\n",
    "        Pmf.__init__(self)\n",
    "        for hypo in hypos:\n",
    "            self.Set(hypo, 1)\n",
    "        self.Normalize()\n",
    "\n",
    "    def Update(self, data):\n",
    "        \"\"\"Updates each hypothesis based on the data.\n",
    "\n",
    "        data: any representation of the data\n",
    "        \"\"\"\n",
    "        for hypo in self.Values():\n",
    "            like = self.Likelihood(data, hypo)\n",
    "            self.Mult(hypo, like)\n",
    "        self.Normalize()\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        \"\"\"Compute the likelihood of the data under the hypothesis.\n",
    "\n",
    "        hypo: string name of the door where the prize is\n",
    "        data: string name of the door Monty opened\n",
    "        \"\"\"\n",
    "        if hypo == data:\n",
    "            return 0\n",
    "        elif hypo == 'A':\n",
    "            return 0.5\n",
    "        else:\n",
    "            return 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's how we use it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A 0.333333333333\n",
      "B 0.0\n",
      "C 0.666666666667\n"
     ]
    }
   ],
   "source": [
    "pmf = Monty('ABC')\n",
    "pmf.Update('B')\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Suite class\n",
    "\n",
    "Most Bayesian updates look pretty much the same, especially the `Update` method.  So we can encapsulate the framework in a class, `Suite`, and create new classes that extend it.\n",
    "\n",
    "Child classes of `Suite` inherit `Update` and provide `Likelihood`.  So here's the short version of `Monty`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Monty(Suite):\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        if hypo == data:\n",
    "            return 0\n",
    "        elif hypo == 'A':\n",
    "            return 0.5\n",
    "        else:\n",
    "            return 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And it works."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A 0.333333333333\n",
      "B 0.0\n",
      "C 0.666666666667\n"
     ]
    }
   ],
   "source": [
    "pmf = Monty('ABC')\n",
    "pmf.Update('B')\n",
    "pmf.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The M&M problem\n",
    "\n",
    "M&Ms are small candy-coated chocolates that come in a variety of\n",
    "colors.  Mars, Inc., which makes M&Ms, changes the mixture of\n",
    "colors from time to time.\n",
    "\n",
    "In 1995, they introduced blue M&Ms.  Before then, the color mix in\n",
    "a bag of plain M&Ms was 30% Brown, 20% Yellow, 20% Red, 10%\n",
    "Green, 10% Orange, 10% Tan.  Afterward it was 24% Blue , 20%\n",
    "Green, 16% Orange, 14% Yellow, 13% Red, 13% Brown.\n",
    "\n",
    "Suppose a friend of mine has two bags of M&Ms, and he tells me\n",
    "that one is from 1994 and one from 1996.  He won't tell me which is\n",
    "which, but he gives me one M&M from each bag.  One is yellow and\n",
    "one is green.  What is the probability that the yellow one came\n",
    "from the 1994 bag?\n",
    "\n",
    "Here's a solution:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class M_and_M(Suite):\n",
    "    \"\"\"Map from hypothesis (A or B) to probability.\"\"\"\n",
    "\n",
    "    mix94 = dict(brown=30,\n",
    "                 yellow=20,\n",
    "                 red=20,\n",
    "                 green=10,\n",
    "                 orange=10,\n",
    "                 tan=10,\n",
    "                 blue=0)\n",
    "\n",
    "    mix96 = dict(blue=24,\n",
    "                 green=20,\n",
    "                 orange=16,\n",
    "                 yellow=14,\n",
    "                 red=13,\n",
    "                 brown=13,\n",
    "                 tan=0)\n",
    "\n",
    "    hypoA = dict(bag1=mix94, bag2=mix96)\n",
    "    hypoB = dict(bag1=mix96, bag2=mix94)\n",
    "\n",
    "    hypotheses = dict(A=hypoA, B=hypoB)\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        \"\"\"Computes the likelihood of the data under the hypothesis.\n",
    "\n",
    "        hypo: string hypothesis (A or B)\n",
    "        data: tuple of string bag, string color\n",
    "        \"\"\"\n",
    "        bag, color = data\n",
    "        mix = self.hypotheses[hypo][bag]\n",
    "        like = mix[color]\n",
    "        return like"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's an update:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A 0.740740740741\n",
      "B 0.259259259259\n"
     ]
    }
   ],
   "source": [
    "suite = M_and_M('AB')\n",
    "suite.Update(('bag1', 'yellow'))\n",
    "suite.Update(('bag2', 'green'))\n",
    "suite.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise:**  Suppose you draw another M&M from `bag1` and it's blue.  What can you conclude?  Run the update to confirm your intuition."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A 0.0\n",
      "B 1.0\n"
     ]
    }
   ],
   "source": [
    "suite.Update(('bag1', 'blue'))\n",
    "suite.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise:**  Now suppose you draw an M&M from `bag2` and it's blue.  What does that mean?  Run the update to see what happens."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exercises"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise:** This one is from one of my favorite books, David MacKay's \"Information Theory, Inference, and Learning Algorithms\":\n",
    "\n",
    "> Elvis Presley had a twin brother who died at birth.  What is the probability that Elvis was an identical twin?\"\n",
    "    \n",
    "To answer this one, you need some background information: According to the Wikipedia article on twins:  ``Twins are estimated to be approximately 1.9% of the world population, with monozygotic twins making up 0.2% of the total---and 8% of all twins.''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "**Exercise:** Let's consider a more general version of the Monty Hall problem where Monty is more unpredictable.  As before, Monty never opens the door you chose (let's call it A) and never opens the door with the prize.  So if you choose the door with the prize, Monty has to decide which door to open.  Suppose he opens B with probability `p` and C with probability `1-p`.  If you choose A and Monty opens B, what is the probability that the car is behind A, in terms of `p`?  What if Monty opens C?\n",
    "\n",
    "Hint: you might want to use SymPy to do the algebra for you. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sympy import symbols\n",
    "p = symbols('p')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "**Exercise:** According to the CDC, ``Compared to nonsmokers, men who smoke are about 23 times more likely to develop lung cancer and women who smoke are about 13 times more likely.''  Also, among adults in the U.S. in 2014:\n",
    "\n",
    "> Nearly 19 of every 100 adult men (18.8%)\n",
    "> Nearly 15 of every 100 adult women (14.8%)\n",
    "\n",
    "If you learn that a woman has been diagnosed with lung cancer, and you know nothing else about her, what is the probability that she is a smoker?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise** In Section 2.3 I said that the solution to the cookie problem generalizes to the case where we draw multiple cookies with replacement.\n",
    "\n",
    "But in the more likely scenario where we eat the cookies we draw, the likelihood of each draw depends on the previous draws.\n",
    "\n",
    "Modify the solution in this chapter to handle selection without replacement. Hint: add instance variables to Cookie to represent the hypothetical state of the bowls, and modify Likelihood accordingly. You might want to define a Bowl object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
